package com.xingkeduo.business.order.controller;

import com.alibaba.fastjson.JSON;
import com.xingkeduo.business.order.domain.CutomerQueyService;
import com.xingkeduo.business.order.domain.OrderDomainService;
import com.xingkeduo.business.order.domain.OrderQueryService;
import com.xingkeduo.business.order.domain.OrderRefundDomainService;
import com.xingkeduo.business.order.service.OrderService;
import com.xingkeduo.dto.PriceDto;
import com.xingkeduo.dto.enums.OrderQueryStatus;
import com.xingkeduo.dto.enums.OrderQueryTypeEnum;
import com.xingkeduo.dto.param.*;
import com.xingkeduo.dto.payment.PayeeOrderResponseDto;
import com.xingkeduo.dto.response.*;
import com.xingkeduo.pojo.enums.GatheringType;
import com.xingkeduo.pojo.table.CustomerService;
import com.xingkeduo.pojo.table.Order;
import com.xingkeduo.utils.PageResponseDTO;
import com.xingkeduo.utils.QRCodeUtils;
import com.xingkeduo.utils.ResponseUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.xingkeduo.utils.Constant.API_URL_PREFIX;


@RestController
@RequestMapping(API_URL_PREFIX + "/order/customer")
@Slf4j
public class CutomerServiceController {

    @Resource
    private CutomerQueyService cutomerQueyService;

    /**
    * @description: 查询售后记录
    * @author: ch
    * @Param [cutomerQueryDto]
    * @return org.springframework.http.ResponseEntity
    * @date: 2019-07-10 15:15
    **/
    @GetMapping("/query")
    public ResponseEntity query(CutomerQueryDto cutomerQueryDto){
        return new ResponseEntity<>(ResponseUtils.getSuccess(cutomerQueyService.selectListPage(cutomerQueryDto)), HttpStatus.OK);
    }

    /**
    * @description: 添加售后记录
    * @author: ch
    * @Param [cutomerParam]
    * @return org.springframework.http.ResponseEntity
    * @date: 2019-07-10 15:16
    **/
    @PostMapping("/append")
    public ResponseEntity add(@RequestBody @Valid CutomerParam cutomerParam){
        return new ResponseEntity<>(ResponseUtils.getSuccess(cutomerQueyService.initCutomer(cutomerParam)), HttpStatus.OK);
    }

    /**
    * @description: 更新售后记录
    * @author: ch
    * @Param [cutomerParam]
    * @return org.springframework.http.ResponseEntity
    * @date: 2019-07-10 15:31
    **/
    @PostMapping("/update")
    public ResponseEntity update(@RequestBody @Valid CutomerParam cutomerParam){
        return new ResponseEntity<>(ResponseUtils.getSuccess(cutomerQueyService.updateCutomer(cutomerParam)), HttpStatus.OK);
    }


    /**
    * @description: 获取订单的售后状态
    * @author: ch
    * @Param [orderNos]
    * @return org.springframework.http.ResponseEntity
    * @date: 2019-08-06 16:21
    **/
    @GetMapping("/cutomer/list")
    public ResponseEntity cutomerList(String[] orderNos) {
        List<Object>  lists = cutomerQueyService.cutomerList(orderNos);
        return new ResponseEntity<>(ResponseUtils.getSuccess(lists), HttpStatus.OK);
    }


}



